﻿#region
using System;
using System.ComponentModel;
using Nonsul.CoreModule;

#endregion

namespace %Namespace%
{
    [ToolboxItem(true)]
    [DefaultEvent("Searched")]
    public partial class %Entity%SearchControl : SearchControl
    {
        public %Entity%SearchControl()
        {
            InitializeComponent();
        }

        #region overriden properties
        #endregion

        #region overriden methods
        public override void RaiseSearch()
        {
            OnSearched(txeKeyword.Text);
        }
        #endregion

        #region Searched event things for C# 3.0
        public event EventHandler<SearchedEventArgs> Searched;

        protected virtual void OnSearched(SearchedEventArgs e)
        {
            if (Searched != null)
                Searched(this, e);
        }

        protected virtual void OnSearched(string keyword)
        {
            OnSearched(new SearchedEventArgs(keyword));
        }

        protected virtual SearchedEventArgs OnSearchedWithReturn(string keyword)
        {
            SearchedEventArgs args = new SearchedEventArgs(keyword);
            OnSearched(args);

            return args;
        }

        public class SearchedEventArgs : EventArgs
        {
            public string Keyword { get; set; }

            public SearchedEventArgs()
            {
            }

            public SearchedEventArgs(string keyword)
            {
                Keyword = keyword;
            }
        }
        #endregion
    }
}